<include file="Public:header" />
<div class="pad_10">
  <form action="" method="post" name="myform" id="myform">
  <input name="level" id="level" type="hidden" value="{$info['level']}">
    <table cellpadding="2" cellspacing="1" class="table_form" width="100%">
      <tr>
        <th width="80">目标级别：</th>
        <td>
        <switch name="info['level']" >
        <case value="1">一级菜单</case>
        <case value="2">二级菜单</case>
        <default />三级菜单
        </switch>
        </td>
      </tr>
      <tr>
        <th width="80">上级菜单：</th>
        <td>
        <select name="firstMenu" id="firstMenu" onchange="getSecondMenu()">
            <volist name="info['firstMenu']" id="vo">
              <option value="{$vo.id}">{$vo.name}</option>
            </volist>
          </select>
          <select name="secondMenu" id="secondMenu" style="display:none">
          <option value="0}">请选择二级菜单</option>
          </select>
          </td>
      </tr>
      <tr>
        <th width="80">标题：</th>
        <td><input type="text" name="info[subject]" id="subject"
			size="30" class="input-text"></td>
      </tr>
      <input type="submit" name="dosubmit" id="dosubmit" class="dialog" value=" 提交 ">
    </table>
  </form>
</div>
</body>
</html>
<script type="text/javascript">
$(function(){
	var level = $("#level").val();
	if(level==3){
		$("#secondMenu").show();
	}

	$('#myform').ajaxForm({
		beforeSubmit:  checkForm,
		success:       complete,
		dataType: 'json'
	});
	function checkForm(){
		if($('#name').val().length < 2){
			$('#name').focus();
			art.dialog({id:'TNCICC',content: '菜单名称不能少于2个字符！',time: 2,icon:'succeed'});
			return false;
		}else if($('#model').val() == ''){
			art.dialog({id:'TNCICC',content: '模块名不能为空！',time: 2,icon:'succeed'});
			return false;
		}else if($('#fun').val() == ''){
			art.dialog({id:'TNCICC',content: '方法名不能为空！',time: 2,icon:'succeed'});
			return false;
		}else{
			return true;
		}
	}

	var origin = $.artDialog.open.origin;
    function complete(data){
		art.dialog({id:'TNCICC',content: data.info,time: 2,icon:'succeed'});
		if(data.status==1)  setTimeout(function(){origin.location.reload();},1000);
		closeWin(1500);
    }
})


function moveMenu(){
	var level = $("#level option:selected").val();
	openWinBox('__URL__/moveMenu/level/'+level,'添加菜单',500,200);

}

function showFirstMenu(val){
	if(val==1){
		$("#firstMenu").hide();
		$("#secondMenu").hide();
	}else if(val==2){
		$("#firstMenu").show();
		$("#secondMenu").hide();
	}else{
		$("#firstMenu").show();
		$("#secondMenu").show();
	}
}
function getSecondMenu(){
	var pid=
	pid = parseInt(pid);
		$.ajax({
			url:'__URL__/getMenuList/randNum/'+Math.random(),
			dataType:'json',
			data:encodeURI('pid='+pid),
			success:function(data){
				var menuArr = data.data;
				var num = menuArr.length;
					$("#secondMenu").empty();
					for(var i=0; i<num; i++){
						$("#secondMenu").append("<option value=\""+menuArr[i]['id']+"\">"+menuArr[i]['name']+"</option>");
					}
			}
		});
	}

</script>